<?php /*a:2:{s:64:"H:\xampp\htdocs\www\lqb\application\admin\view\list\product.html";i:1563842112;s:63:"H:\xampp\htdocs\www\lqb\application\admin\view\public\head.html";i:1563863606;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台管理系统 - Layui</title>
    <script type="text/javascript" src="/static/admin/layui/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="/static/admin/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css" />
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="/admin/Product/productListStatus">已上架商品</a></li>
            <li class="layui-nav-item"><a href="#" id="lqb">预览</a></li>
            <li class="layui-nav-item"><a href="/admin/Registered/noMoney" >没有借款</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    <?php echo think\facade\Session::get('user','user_session'); ?>
                </a>
                <!--<dl class="layui-nav-child">-->
                    <!--<dd><a href="">基本资料</a></dd>-->
                    <!--<dd><a href="">安全设置</a></dd>-->
                <!--</dl>-->
            </li>
            <li class="layui-nav-item"><a href="/admin/Index/quit">退出</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-shrink=""  lay-filter="test">
                <li class="layui-nav-item <?php if((app('request')->path() == 'admin/Product/productList') OR (app('request')->path() == 'admin/Click/index') OR (app('request')->path() == 'admin/Product/addProduct') OR (app('request')->path() == 'admin/Category/index')
              OR (app('request')->path() == 'admin/Category/addCategory')): ?>layui-nav-itemed<?php endif; ?>">
                    <a class="" href="javascript:;">产品管理</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'admin/Product/productList'): ?>layui-this<?php endif; ?>"><a href="/admin/Product/productList">产品列表</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Click/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Click/index">产品点击</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Product/addProduct'): ?>layui-this<?php endif; ?>"><a href="/admin/Product/addProduct">添加产品</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Category/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Category/index">产品分类</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Category/addCategory'): ?>layui-this<?php endif; ?>"><a href="/admin/Category/addCategory">添加分类</a></dd>
                        <!--<dd><a href="/admin/Category/index">推广等级</a></dd>-->
                        <!--<dd><a href="/admin/Grade/fetch_add_grade">添加等级</a></dd>-->
                    </dl>
                </li>
                <li class="layui-nav-item <?php if((app('request')->path() == 'admin/Banner/allBanner') OR (app('request')->path() == 'admin/Banner/addBanner')): ?>layui-nav-itemed<?php endif; ?>">
                    <a href="javascript:;">轮播图</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'admin/Banner/allBanner'): ?>layui-this<?php endif; ?>"><a href="/admin/Banner/allBanner">轮播图</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Banner/addBanner'): ?>layui-this<?php endif; ?>"><a href="/admin/Banner/addBanner">添加轮播图</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item <?php if((app('request')->path() == 'admin/Popularize/index') OR (app('request')->path() == 'admin/Popularize/Management') OR (app('request')->path() == 'admin/Popularize/getAllPopularize')
              OR (app('request')->path() == 'admin/Registered/index')): ?>layui-nav-itemed<?php endif; ?>">
                    <a href="javascript:;">推广管理</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'admin/Popularize/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Popularize/index">添加推广账号</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Popularize/Management'): ?>layui-this<?php endif; ?>"><a href="/admin/Popularize/Management">管理推广账号</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Popularize/getAllPopularize'): ?>layui-this<?php endif; ?>"><a href="/admin/Popularize/getAllPopularize">查看所有推广</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Registered/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Registered/index">查看所有注册</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item  <?php if((app('request')->path() == 'admin/Admin/index') OR (app('request')->path() == 'admin/Admin/adminList')): ?>layui-nav-itemed<?php endif; ?>">
                    <a href="javascript:;">登陆账号</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'admin/Admin/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Admin/index">添加后台登陆账号</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Admin/adminList'): ?>layui-this<?php endif; ?>"><a href="/admin/Admin/adminList">管理后台登陆账号</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item <?php if((app('request')->path() == 'admin/File/index') OR (app('request')->path() == 'admin/Log/index')): ?>layui-nav-itemed<?php endif; ?>">
                    <a href="javascript:;">系统管理</a>
                    <dl class="layui-nav-child">
                        <dd class="<?php if(app('request')->path() == 'admin/File/index'): ?>layui-this<?php endif; ?>"><a href="/admin/File/index">图片管理</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Log/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Log/index">操作日志</a></dd>
                        <dd class="<?php if(app('request')->path() == 'admin/Error/index'): ?>layui-this<?php endif; ?>"><a href="/admin/Error/index">错误日志</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div id="main" class="layui-body">
        <!-- 内容主体区域 -->
        <blockquote class="layui-elem-quote" style="margin: 15px">内容变量</blockquote>
        

<form class="layui-form" style="margin: 20px">
    <div class="demoTable">
        条件搜索：
        <div class="layui-inline">
            <select name="status">
                <option value="">全部状态</option>
                <option value="1">正常</option>
                <option value="0">禁用</option>
            </select>
        </div>
        <div class="layui-inline">
            <select name="grade">
                <option value="">推广等级</option>
                <?php if(is_array($gradeName) || $gradeName instanceof \think\Collection || $gradeName instanceof \think\Paginator): $i = 0; $__LIST__ = $gradeName;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                <option value="<?php echo htmlentities($vo['grade_name']); ?>"><?php echo htmlentities($vo['grade_name']); ?></option>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
        <div class="layui-inline">
            <select name="category_id">
                <option value="">贷款类型</option>
                <?php if(is_array($categoryName) || $categoryName instanceof \think\Collection || $categoryName instanceof \think\Paginator): $i = 0; $__LIST__ = $categoryName;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                <option value="<?php echo htmlentities($vo['category_id']); ?>"><?php echo htmlentities($vo['category_name']); ?></option>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
        <div class="layui-inline">
            <input class="layui-input" name="title"  autocomplete="off" placeholder="产品名称">
        </div>
        <div class="layui-input-inline">
            <input name="time" type="text" class="layui-input" id="date" placeholder="输入时间范围">
        </div>
        <div class="layui-inline">
            <button class="layui-btn" lay-filter="submit" lay-submit>搜索</button>
            <button class="layui-btn layui-btn-primary"  lay-filter="submit" lay-submit>重置</button>
        </div>

    </div>
</form>

<table class="layui-hide" id="all" lay-filter="all" lay-data="{id: 'sousuo'}"></table>

<script type="text/html" id="img_url">
    <img src="{{d.img_url}}" style="height: 24px"/>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-sm" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
</script>

<script type="text/html" id="application_url">
    <a class="layui-btn layui-btn-sm" lay-event="open_url">申请链接</a>
</script>

<script type="text/html" id="status">
    {{#  if(d.status == 1){ }}<button class="layui-btn layui-btn-xs">上架</button> {{#  } }}
    {{#  if(d.status == 0){ }}<button class="layui-btn layui-btn-xs layui-btn-disabled">下架</button> {{#  } }}
    {{#  if(d.repeat == 1){ }}<button class="layui-btn layui-btn-warm layui-btn-xs">重复</button> {{#  } }}
</script>

<script>
    layui.use(['table','layer','form','laydate'], function(){
        var table = layui.table;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var form = layui.form;
        table.render({
            elem: '#all'
            ,url:'/admin/Product/getAllProductByLayui'
            ,toolbar: '#toolbarDemo'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'product_id', title:'ID',  fixed: 'left', unresize: true, sort: true}
                ,{field:'img_url', title:'缩略图',width:80,toolbar: '#img_url'}
                ,{field:'title', title:'产品名称'}
                ,{field:'grade', title:'推广等级'}

                ,{field:'px', title:'排序',sort: true}
                ,{field:'application', title:'申请人数'}
                ,{field:'success_application', title:'成功人数'}
                ,{field:'price_min', title:'最高额度'}
                ,{field:'price_max', title:'最低额度'}
                ,{field:'limit_time', title:'期限'}
                ,{field:'day_interest', title:'日利息'}
                ,{field:'application_url', title:'申请链接',toolbar: '#application_url',}
                ,{field:'status', title:'状态',width:120, templet:'#status',event:"status"}
                ,{field:'add_time', title:'添加时间'}
                ,{field:'up_time', title:'修改时间'}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
            ,page: true
        });
        // 表格重载 用于搜索
        form.on('submit(submit)', function(data){
            var field=data.field;
            if($(data.elem).html()=="重置"){
                $("input").val("");
                field="";
                table.render({
                    elem: '#all'
                    ,url:'/admin/Product/getAllProductByLayui'
                    ,toolbar: '#toolbarDemo'
                    ,cols: [[
                        {type: 'checkbox', fixed: 'left'}
                        ,{field:'product_id', title:'ID',  fixed: 'left', unresize: true, sort: true}
                        ,{field:'img_url', title:'缩略图',width:80,toolbar: '#img_url'}
                        ,{field:'title', title:'产品名称'}
                        ,{field:'grade', title:'推广等级'}

                        ,{field:'px', title:'排序',sort: true}
                        ,{field:'application', title:'申请人数'}
                        ,{field:'success_application', title:'成功人数'}
                        ,{field:'price_min', title:'最高额度'}
                        ,{field:'price_max', title:'最低额度'}
                        ,{field:'limit_time', title:'期限'}
                        ,{field:'day_interest', title:'日利息'}
                        ,{field:'application_url', title:'申请链接',toolbar: '#application_url',}
                        ,{field:'status', title:'状态',width:120, templet:'#status',event:"status"}
                        ,{field:'add_time', title:'添加时间'}
                        ,{field:'up_time', title:'修改时间'}
                        ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
                    ]]
                    ,page: true
                });
            }
            if($(data.elem).html()=="搜索") {
                table.reload('all', {
                    url: '/admin/Product/ConditionByProduct',
                    method: 'post',
                    where: {field}
                });
            }
            return false;
        });

        table.on('tool(all)', function(obj){
            var data = obj.data; //获得当前行数据
            var id = obj.data.product_id;
            var url = obj.data.application_url;
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            console.log(obj.data);
            if(obj.event == 'status'){
                var new_status = data.status;
                if(data.status){
                    new_status = 0;
                    form.render();
                }else {
                    new_status = 1
                    form.render();
                }
                console.log(data.status+'...');
                $.post("<?php echo Url('admin/Popularize/upStatus'); ?>",{'id': data.id , 'status': new_status},function(data){
                    console.log(data.code);
                    if(data.code = 200){
                        console.log('success');
                    }
                })
            }
            if(obj.event == 'edit'){
                console.log('edit_1');
                window.location.href= ("/admin/Product/addProduct/id/"+id);
            }
            if(obj.event == 'del'){
                layer.confirm('真的删除行么', function(index){
                    layer.close(index);
                    console.log(data);
                    //向服务端发送删除指令
                    $.post("<?php echo Url('admin/Product/del'); ?>",{'id': data.product_id},function(data){
                        console.log(data.code);
                        if(data.code == 300 ||data.code == 500){
                            layer.msg('删除失败！！！请重试');
                        }
                        if(data.code == 200){
                            layer.msg('删除成功！！！');
                            obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                        }
                    })
                });
            }
            if(obj.event == 'open_url'){
                //iframe层-父子操作
                layer.open({
                    type: 2,
                    area: ['700px', '450px'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: url
                });
            }
        });
        $('#all').on('click', function(){
            layer.msg('hello');
        });
        laydate.render({
            elem: '#date' //指定元素
            ,range: '.'
        });
    });
</script>



    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 感谢
    </div>
</div>
<script>
    //JavaScript代码区域
    var url = window.location.href;
    var callback = url.split("&").pop().replace(/callback=/, "");

    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    layui.use(['element','layer'], function(){
        var element = layui.element;
        var layer = layui.layer;
        $("#lqb").click(function(){
            layer.open({
                type: 2,
                area: ['840px', '480px'],
                fixed: false, //不固定
                maxmin: true,
                content: 'http://www.lqb2018.cn',
            });
        });
    });
</script>
</body>
</html>